package com.xjtu.mybatisplus.web.controller.review;

//import com.xjtu.mybatisplus.common.JsonResponse.PageJsonResponse;
//import com.xjtu.mybatisplus.common.JsonResponse.JsonResponse;
import com.xjtu.mybatisplus.common.JsonResponse;
//import com.xjtu.mybatisplus.common.JsonResponse.PageJsonResponse;
import com.xjtu.mybatisplus.common.result.PageResult;
import com.xjtu.mybatisplus.model.domain.Article;
import com.xjtu.mybatisplus.model.dto.ReviewDto;
import com.xjtu.mybatisplus.model.vo.reviewVo.ReviewStaticVo;
import com.xjtu.mybatisplus.model.vo.reviewVo.ReviewVo;
import com.xjtu.mybatisplus.model.vo.reviewVo.ReviewerVo;
import com.xjtu.mybatisplus.service.ReviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 *
 *  前端控制器
 *
 *
 * @author lsong
 * @since 2023-12-27
 * @version v1.0
 */
@RestController
@RequestMapping("api/admin/review")
@Api(tags = "审核接口")
public class ReviewController {



    @Autowired
    private ReviewService reviewService;

    @GetMapping("add")
    @ApiOperation("模拟插入审核")
    public JsonResponse insertById(@RequestParam(value = "articleId",required = true) Long articleId) {
        return reviewService.insert(articleId, 1);
    }
    @GetMapping("task")
    @ApiOperation("某个员工申请审核任务")
    public JsonResponse applyTask(@RequestParam(value ="reviewId",required = true) Long reviewId) {
        return reviewService.applyReview(reviewId);
    }
    @GetMapping("tasks")
    @ApiOperation("某个员工获取自己的审核任务")
    public JsonResponse<PageResult> getTaskList(@RequestParam(value ="reviewId",required = true)Long reviewId,
                                  @RequestParam(value ="page",required = false, defaultValue = "1") Integer page,
                                  @RequestParam(value ="pageSize",required = false, defaultValue = "10") Integer pageSize) {
        return reviewService.getTaskById(reviewId, page, pageSize);
    }


    @GetMapping("list")
    @ApiOperation("获取所有的审核信息")
    public JsonResponse<PageResult> getAllList(@RequestParam(value ="page",required = false, defaultValue = "1") Integer page,
                                 @RequestParam(value ="pageSize",required = false, defaultValue = "10") Integer pageSize) {

        return reviewService.getAllTask(page, pageSize);
    }



    @GetMapping("undo")
    @ApiOperation("获取所有未审核信息")
    public JsonResponse<List<ReviewVo>> getUndoList(@RequestParam(required = false, defaultValue = "-1") Long reviewId){
        return reviewService.getUndoList(reviewId);

    }
    @PutMapping("task")
    @ApiOperation("上传审核信息")
    public JsonResponse updateTask(@RequestBody ReviewDto reviewDto) {

        return reviewService.update(reviewDto);
    }

    @GetMapping("reviewer")
    @ApiOperation("获取所有审核员及其审核文章数量")
    public JsonResponse<List<ReviewerVo>> getReviewers(){
        return reviewService.getReviewerList();
    }
    @GetMapping("article")
    @ApiOperation("审核查看文章详情")
    public JsonResponse<Article> getReviewArticle(@RequestParam(value ="articleId",required = true) Long articleId){
        return reviewService.getArticle(articleId);
    }

    @GetMapping("static")
    @ApiOperation("获取所有审核数，今日审核数，所有已完成数，今日已完成数")
    public JsonResponse<ReviewStaticVo> getReviewStatic(@RequestParam(required = false, defaultValue = "-1") Long reviewId) {
        return reviewService.getStatic(reviewId);
    }






}

